/*
 * Copyright (c) 2022 FuZhou Lockzhiner Electronic Co., Ltd. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef __IOT_CLOUD_IA_EXAMPLE_H__
#define __IOT_CLOUD_IA_EXAMPLE_H__

#include <cJSON.h>
#include "ohos_init.h"
#include "los_task.h"
#include "oc_mqtt.h"
#include "e53_intelligent_agriculture.h"
#include "lz_hardware.h"
#include "config_network.h"

#include "stdlib.h"
#include <string.h>
#include <strings.h>

#define ROUTE_SSID                      "深职物联"
#define ROUTE_PASSWORD                  "88888888"

#define MSG_QUEUE_LENGTH                16
#define BUFFER_LEN                      50

#define CLIENT_ID                       "66105f4771d845632a0403e7_E53_IA_0_0_2024041205"
#define USERNAME                        "66105f4771d845632a0403e7_E53_IA"
#define PASSWORD                        "08e6aa49ea8f2adc524b9d5d84bb02bd26d6565021e3e2b4f19ebf1b474f1035"

typedef struct
{
    float lum;
    float temp;
    float hum;
    int rain;
    float ppm;
    int fire_flag;
    int infra_red_flag;
    int touch_key;
} ia_report_t;

typedef struct
{
    en_msg_type_t msg_type;
    cmd_t cmd;
    ia_report_t report;
} ia_msg_t;

typedef struct
{
    int connected;
    int led;
    int motor;
} ia_status_t;

static unsigned int m_ia_MsgQueue;
static ia_status_t m_app_status;

/***************************************************************
* 函数名称: ia_deal_report_msg
* 说    明: 上报数据到华为云上
* 参    数: report：上报消息指针
* 返 回 值: 无
***************************************************************/
void ia_deal_report_msg(ia_report_t *report);

/***************************************************************
* 函数名称: ia_cmd_response_callback
* 说    明: 华为云命令处理回调函数
* 参    数: recv_data：接收的数据指针
*           recv_size：接收数据的大小
*           resp_data：响应数据的指针
*           resp_size：响应数据的大小
* 返 回 值: 无
***************************************************************/
void ia_cmd_response_callback(uint8_t *recv_data, size_t recv_size, uint8_t **resp_data, size_t *resp_size);

/***************************************************************
* 函数名称: iot_cloud_ia_thread
* 说    明: 华为云线程
* 参    数: 无
* 返 回 值: 无
***************************************************************/
void iot_cloud_ia_thread();

/***************************************************************
* 函数名称: e53_ia_thread
* 说    明: E53线程
* 参    数: 无
* 返 回 值: 无
***************************************************************/
void e53_ia_thread();

/***************************************************************
* 函数名称: iot_cloud_ia_example
* 说    明: 华为云例程
* 参    数: 无
* 返 回 值: 无
***************************************************************/
void iot_cloud_ia_example();

#endif /*__IOT_CLOUD_IA_EXAMPLE_H__*/
